how to get the history of an work item?
Hi,
Does anybody know how to get the history of an work item? By history, I mean changes to a given work item. I tried IAuditable.getPredecessorState on an IWorkItem, but when I attempted to get the fields of the predecessor state, I got an IllegalStateException. The error message says "Attempting to get unset feature: InternalState". It's clear that I'm not doing things right, but I have no idea how I should do it correctly. Please help! Thanks! Annie |
Accepted answer
You probably fetched the work item with only part of its properties, you can use IItemManager.fetchCompleteState() to get the full item in its historical state. If you want to get the full history you can also get all state handles at once using IItemManager.fetchAllStateHandles() instead of walking the history using IAuditable.getPredecessorState().
Regards, Christof Jazz Work Item team Ralph Schoon selected this answer as the correct answer
|
6 other answers
Thanks Christof! What you suggested worked great!
I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.) Thanks! Annie Comments
Dashrath Kale
commented Jun 18 '15, 3:15 a.m.
Hi Annie
|
You can use IItem.modified() (which returns a Date instead of a Timestamp).
Regards, Christof Jazz Work Item team |
I am using RTC version 3.0, and accessing JAVA api.
I am facing the following problem while trying to fetch the enumerations: Code snippet: IEnumeration<IPriority> enums = (IEnumeration<IPriority>)workItemClient.resolveEnumeration(attribute, null); Also, the same error occurs, while doing following operation: IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", new SysoutProgressMonitor()); Exception in thread "main" java.lang.IllegalArgumentException at com.ibm.team.process.internal.common.util.AbstractProcess.computeConfigurationData(AbstractProcess.java:328) at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:313) at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:299) at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:68) at com.ibm.team.workitem.common.internal.EnumerationManager$InternalEnumerations.resolve(EnumerationManager.java:52) at com.ibm.team.workitem.common.internal.EnumerationManager.updateCache(EnumerationManager.java:198) at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:117) at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:74) at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65) at com.ibm.team.workitem.common.internal.EnumerationManager.internalResolve(EnumerationManager.java:173) at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:169) at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:453) at CreateWorkItem.main(CreateWorkItem.java:147) |
Hello Christof,
I recently went through this post while trying to search any article that explains on reporting out of the history details. This post seems something similar. I would like to start writing reports that can fetch the changes of a work item along with the state changes. Could you please if there is a way I can achieve this, if so how? Many Thanks, Regards, Sunita Thanks Christof! What you suggested worked great! |
We would fetch the user id from the predecessor state of a work-item. We are using the code below: ITeamRepository repo = ... IWorkItem wi = ... IAuditable predecessorState = repo.itemManager().fetchCompleteState(wi.getPredecessorState(), null); IContributorHandle contributorH = predecessorState.getModifiedBy(); IContributor contributor = (IContributor) repo.itemManager().fetchCompleteItem(contributorH, IItemManager.DEFAULT, null); String userId = contributor.getUserId()); But the userId is coming from the last contributor who changed the work-item's state, not from the predeccessor... Any advice? Thanks in advance.
|
can you share the snippet for the same so that it will helpful for others also. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.